--[[
*名称:PurchaseLayer
*描述:支付界面
*版权:Copyright © 2016-2018 深圳市三只小熊科技有限公司 版权所有
*作者:管理员
*创建日期:
*修改日期:
*备注:该类属于baseClsss请勿修改，如需修改请详询管理员
]]
-- local BasePart = require("packages.mvc.BasePart")
local CURRENT_MODULE_NAME = ...
local PurchasePart = class("PurchasePart", PokerPartBase) --登录模块
local cjson = require "cjson"
PurchasePart.DEFAULT_PART = {
    "LoadingPart", 
    "PayWayDialogPart", 
}
PurchasePart.DEFAULT_VIEW = "purchaselayer"
--[
-- @brief 构造函数
--]
function PurchasePart:ctor(owner)
    PurchasePart.super.ctor(self, owner)
    self:initialize()
end

--[
-- @override
--]
function PurchasePart:initialize()
    self.purchase_config = {} --当前商品配置
    cc.bind(self, "purchaselogic");
end

--激活模块
function PurchasePart:activate(gameId, data)
    -- self.owner:startLoading()
    -- gameId = 262401 --临时测试数据
    self.game_id = gameId
    PurchasePart.super.activate(self, CURRENT_MODULE_NAME)
    self.purchase_config = data;
    self:doView("initConfig", self.purchase_config);
end
---
-- 选择商品
-- @DateTime 2017-11-02
-- @param    goodsInfo [description]
-- @return    [description]
--
function PurchasePart:startPay(goodsInfo)
    Log.d("PurchasePart:startPay goodsInfo: ", goodsInfo);
    if ISAPPSTORE then
        self:requestOrder(PokerPayType.IAP_PAY, goodsInfo.id);
    else
        Log.d("PurchasePart:startPay open PayWayDialogPart");
        self:activatePart("PayWayDialogPart", goodsInfo);
    end
end

function PurchasePart:getPartId()
    return "PurchasePart"
end

return PurchasePart
